package org.showData;

import com.scm.all.export.ByteUtils;
import com.scm.all.export.ModuleOperationUtilsJNI;
import com.scm.x64.export.MemoryOperationUtilsX64;
import com.scm.x86.export.MemoryOperationUtilsX86;
import javafx.scene.control.TextArea;
import org.apache.commons.lang3.StringUtils;
import org.openProcess.StageWindowsProcessAndListView;

import java.util.Arrays;
import java.util.TimerTask;

public class StageWindowShowAndPaneAndVBoxAndTextAreaData {
    public static TextArea textArea = new TextArea();
    public static void init(){
        new Thread(new TimerTask() {
            @Override
            public void run() {
                while (true){
                    try {
                        Thread.sleep(50);
                        if(!StringUtils.equals(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText(),"")){
                            if(ModuleOperationUtilsJNI.systemIs32()){
                                if(!StringUtils.equals(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText(),"") && !StringUtils.equals(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText(),null)){
                                    textArea.setText(ByteUtils.bytesToHexString(MemoryOperationUtilsX86.readProcessMemoryByte(StageWindowsProcessAndListView.ProcessIDHandle,Integer.parseInt(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText()),Integer.parseInt(StageWindowShowAndPaneAndTextFindValue.textField.getText()))));
                                }
                            }
                            if(ModuleOperationUtilsJNI.systemIs64()){
                                if(!StringUtils.equals(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText(),"") && !StringUtils.equals(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText(),null)){
                                    textArea.setText(ByteUtils.bytesToHexString(MemoryOperationUtilsX64.readProcessMemoryByte(StageWindowsProcessAndListView.ProcessIDHandle,Integer.parseInt(StageWindowShowAndPaneAndVBoxAndHBoxAndLableTextFind.textField.getText()),Integer.parseInt(StageWindowShowAndPaneAndTextFindValue.textField.getText()))));
                                }
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }
}
